#pragma once

#include "model/DHT11.h"
#include "model/OneWire.hpp"
#include "messages.hpp"

namespace actor {

struct DHTActor : rl::Actor<3> {
  using Model = model::OneWire<5>;
  using Parent = rl::Actor<3>;

    enum class Substate {
      none,
      hs_keep_high,
      hs_wait_low,
    };

  void initialize() override;
  void advance_init() override;
  void on_timer();
  void on_edge(bool value);

  void on_request(message::RequestHT &);
  //void refresh();

  rl::ActorId uart_id;

private:
  void handshake_continue();
  void handshake_wait_low();

  Model model;
  Substate substate = Substate::none;
  uint8_t wire_value = 0;
};

} // namespace actor
